/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

import { initByProject, initExecuteCommand, runHvigor } from '../src/common/common';
import * as os from 'os';

describe('test build in task', () => {
  test.concurrent('test tasks', async () => {
    await initByProject('common-test', async (rootProject) => {
      const command = initExecuteCommand({
        tasks: 'tasks'
      });

      const result = await runHvigor(rootProject, command);
      expect(result.stdout).toContain('BUILD SUCCESSFUL');
      expect(result.stdout).toContain('All tasks from hvigor node \'module1');
      expect(result.stdout).toContain('clean - This is module1 clean task');
    });
  });

  test.concurrent('test task-tree', async () => {
    await initByProject('common-test', async (rootProject) => {
      const command = initExecuteCommand({
        tasks: 'taskTree'
      });

      const result = await runHvigor(rootProject, command);
      expect(result.stdout).toContain('BUILD SUCCESSFUL');
      expect(result.stdout).toContain('All tasks dependencies from hvigor node \'module1\'');
      expect(result.stdout).toContain(`:module1:task2${os.EOL}`);
      expect(result.stdout).toContain('\\--- :task1');
    });
  });

});
